<?php
/*
 * @Author: your name
 * @Date: 2020-10-27 11:13:42
 * @LastEditTime: 2020-12-17 13:32:47
 * @LastEditors: Please set LastEditors
 * @Description: 模块关系验证器
 * @FilePath: /special/application/adminapiv3/validate/ModuleRelationValidate.php
 */
namespace app\adminapiv3\validate;

use think\Validate;

class ModuleRelationValidate extends Validate
{
    protected $rule = [
        //主机IP地址
        'ip|主机IP地址' => 'regex:\d{0,3}(\.\d{0,3}$',
        //资产名称
        'name|资产名称' => 'length:1,25',
        // 是否在线
        'online|是否在线' => 'in:0,1',
        // 主机ID
        'host_id|主机ID' => 'require|regex:^\d+(,\d+){0,30}$',
        //模块名
        'module|模块名' => 'require|in:netfilter,disguise,hgshield'
    ];

    //错误消息
    protected $message = [
        'online.in' => '是否在线格式错误'
    ];

    protected $scene = [
        'listFilter' => ['ip','name','online'],
        'add' => ['host_id'],
        'del' => ['host_id']
    ];
}
